home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / tool_wnd / mainwnd.frm < prev    next >
Text File  |  1994-05-25  |  6KB  |  218 lines

  1. VERSION 2.00
  2. Begin Form MainWnd 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Toolbar Demonstration"
  5.    ClientHeight    =   765
  6.    ClientLeft      =   1125
  7.    ClientTop       =   2010
  8.    ClientWidth     =   7245
  9.    Height          =   1455
  10.    Icon            =   MAINWND.FRX:0000
  11.    Left            =   1065
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   765
  15.    ScaleWidth      =   7245
  16.    Top             =   1380
  17.    Width           =   7365
  18.    Begin PictureBox ToolBar 
  19.       Align           =   1  'Align Top
  20.       BackColor       =   &H00C0C0C0&
  21.       BorderStyle     =   0  'None
  22.       Height          =   405
  23.       Left            =   0
  24.       ScaleHeight     =   27
  25.       ScaleMode       =   3  'Pixel
  26.       ScaleWidth      =   483
  27.       TabIndex        =   0
  28.       TabStop         =   0   'False
  29.       Top             =   0
  30.       Width           =   7245
  31.       Begin Label Status 
  32.          AutoSize        =   -1  'True
  33.          BackStyle       =   0  'Transparent
  34.          Caption         =   "Ready"
  35.          FontBold        =   0   'False
  36.          FontItalic      =   0   'False
  37.          FontName        =   "MS Sans Serif"
  38.          FontSize        =   8.25
  39.          FontStrikethru  =   0   'False
  40.          FontUnderline   =   0   'False
  41.          Height          =   195
  42.          Left            =   3060
  43.          TabIndex        =   1
  44.          Top             =   105
  45.          Width           =   465
  46.       End
  47.    End
  48.    Begin Menu Menu_Fil 
  49.       Caption         =   "&Files"
  50.       Begin Menu MenuF_New 
  51.          Caption         =   "&New"
  52.          Shortcut        =   ^N
  53.       End
  54.       Begin Menu MenuF_Ope 
  55.          Caption         =   "&Open..."
  56.          Shortcut        =   ^O
  57.       End
  58.       Begin Menu MenuF_Pri 
  59.          Caption         =   "&Print..."
  60.          Shortcut        =   ^P
  61.       End
  62.       Begin Menu zd1 
  63.          Caption         =   "-"
  64.       End
  65.       Begin Menu MenuF_End 
  66.          Caption         =   "&End"
  67.          HelpContextID   =   1003
  68.       End
  69.    End
  70.    Begin Menu Menu_Opt 
  71.       Caption         =   "&Options"
  72.       Begin Menu MenuO_Qui 
  73.          Caption         =   "&QuickHelp"
  74.          Checked         =   -1  'True
  75.       End
  76.    End
  77.    Begin Menu MenuA_Abo 
  78.       Caption         =   "&About..."
  79.    End
  80. End
  81. Option Explicit
  82.  
  83. Sub Form_Load ()
  84. Dim HSysMenu As Integer, rc As Integer
  85. Dim temp$
  86.     
  87.     stppx = 15
  88.     stppy = 15
  89.     QuickInfo = True
  90.     For rc = 0 To 6
  91.         vbCopyTool ToolWnd.Tool(rc), ToolBar, vbQHTrue
  92.     Next rc
  93.  
  94.     temp$ = "Toolbartext 1|QuickInfo 1"
  95.     vbQHPutString 0, temp$
  96.     temp$ = "Toolbartext 2|QuickInfo 2"
  97.     vbQHPutString 1, temp$
  98.     temp$ = "Toolbartext 3|QuickInfo 3"
  99.     vbQHPutString 2, temp$
  100.     temp$ = "Toolbartext 4|QuickInfo 4"
  101.     vbQHPutString 3, temp$
  102.     temp$ = "Toolbartext 5|QuickInfo 5"
  103.     vbQHPutString 4, temp$
  104.     temp$ = "Toolbartext 6|QuickInfo 6"
  105.     vbQHPutString 5, temp$
  106.     temp$ = "Toolbartext 7|QuickInfo 7"
  107.     vbQHPutString 6, temp$
  108.     Unload ToolWnd
  109.     HSysMenu = GetSystemMenu(Me.hWnd, 0)
  110.     rc = RemoveMenu(HSysMenu, 2, MF_BYPOSITION)
  111.     Me.Height = 1080
  112.     ToolBar.AutoRedraw = True
  113.     ToolBar.Line (201, 5)-(477, 5), RGB(128, 128, 128)
  114.     ToolBar.Line (201, 5)-(201, 21), RGB(128, 128, 128)
  115.     ToolBar.Line (477, 5)-(477, 21), RGB(255, 255, 255)
  116.     ToolBar.Line (201, 21)-(478, 21), RGB(255, 255, 255)
  117.     ToolBar.AutoRedraw = False
  118.     MenuRight MenuA_Abo
  119. End Sub
  120.  
  121. Sub Form_Resize ()
  122. Static tw As Integer
  123.     If Me.WindowState = 1 Then
  124.         If ToolhWnd Then
  125.             tw = True
  126.             Unload ToolWnd
  127.         End If
  128.     Else
  129.         If tw Then
  130.             ToolWnd.Show
  131.         End If
  132.         'FloatingWindow Me.hWnd, False
  133.     End If
  134. End Sub
  135.  
  136. Sub Form_Unload (Cancel As Integer)
  137.     If Me.WindowState = 1 Then WindowState = 0
  138.     If ToolhWnd Then Unload ToolWnd
  139. End Sub
  140.  
  141. Sub MenuA_Abo_Click ()
  142.     MsgBox "(c) 1994, TSAF", 64
  143. End Sub
  144.  
  145. Sub MenuF_End_Click ()
  146.     Unload Me
  147. End Sub
  148.  
  149. Sub MenuO_Qui_Click ()
  150.     MenuO_Qui.Checked = Not MenuO_Qui.Checked
  151.     QuickInfo = MenuO_Qui.Checked
  152. End Sub
  153.  
  154. Sub ToolBar_DblClick ()
  155. Dim h As Integer
  156.     h = 15 * (GetSystemMetrics(15) + GetSystemMetrics(4) + 2 * GetSystemMetrics(33) - GetSystemMetrics(6))
  157.     Me.Height = h
  158.     ToolWnd.Show
  159. End Sub
  160.  
  161. Sub ToolBar_MouseDown (button As Integer, Shift As Integer, x As Single, Y As Single)
  162. Dim sUsed As Integer
  163. Dim temp$
  164.     temp$ = "Ready"
  165.     sUsed = True
  166.     Select Case vbPaintedToolExt(ToolBar, MouseDown, Status)
  167.         Case 0
  168.         Case 1
  169.             If MsgBox("Quit?", 36) = 6 Then sUsed = False: Unload Me
  170.         Case 2
  171.         Case 3
  172.         Case 4
  173.         Case 5
  174.         Case 6
  175.     End Select
  176.     If sUsed Then Me.Show : Status.Caption = temp$
  177. End Sub
  178.  
  179. Sub ToolBar_MouseMove (button As Integer, Shift As Integer, x As Single, Y As Single)
  180. Dim rc As Integer
  181. Dim mPoint As apiPoint
  182. Dim tRect As apiRect
  183. Static mm As Integer
  184.     If QuickInfo Then
  185.         If Not mm Then rc = vbPaintedToolExt(ToolBar, MouseMove, Status)
  186.         If button And Not mm And rc Then
  187.             mm = True
  188.             GetWindowRect ToolBar.hWnd, tRect
  189.             Do
  190.                 DoEvents
  191.                 GetCursorPos mPoint
  192.                 If mPoint.x < tRect.Left Or mPoint.Y < tRect.Top Or mPoint.x > tRect.Right Or mPoint.Y > tRect.Bottom Then
  193.                     If Not ToolhWnd Then
  194.                         Load ToolWnd
  195.                         GetCursorPos mPoint
  196.                         ToolWnd.Move mPoint.x * stppx, mPoint.Y * stppy
  197.                     End If
  198.                     FakeMove ToolWnd
  199.                 Else
  200.                     If ToolhWnd Then Unload ToolWnd
  201.                 End If
  202.             Loop Until GetKeyState(1) >= 0
  203.             GetCursorPos mPoint
  204.             If mPoint.x < tRect.Left Or mPoint.Y < tRect.Top Or mPoint.x > tRect.Right Or mPoint.Y > tRect.Bottom Then
  205.                 ToolBar_DblClick
  206.             Else
  207.                 Unload ToolWnd
  208.             End If
  209.             mm = False
  210.         End If
  211.     End If
  212. End Sub
  213.  
  214. Sub ToolBar_Resize ()
  215.     MakeUpperStatusBar ToolBar
  216. End Sub
  217.  
  218.